|
|
|
| |
|
|
|
|
Notice the use of the CommonDialog control to open the file. Whenever you need to prompt users for file-related action (open, create, save), you should use the CommonDialog control. This is a familiar dialog for your users, and it handles all of the dirty work of scrolling, searching, and so on. |
|
|
|
|
|
|
|
|
|
|
Table 14.2 lists errors that are similar to the File not found error illustrated in Listing 14.9. Errors of this type usually involve giving the user a chance to re-enter the filename or reset some value. Most of the time, you can write an error trap that anticipates these errors, prompts the user to supply the corrected information, and then retries the operation that caused the error. |
|
|
|
|
| Table 14.2. Common general file errors. | | Error Code | Error Message | | 52 | Bad filename or number | | 53 | File not found | | 54 | Bad file mode | | 55 | File already open | | 58 | File already exists | | 59 | Bad record length | | 61 | Disk full | | 62 | Input past end of file | | 63 | Bad record number | | 64 | Bad filename | | 67 | Too many files | | 74 | Can't rename with different drive | | 75 | Path/File access error | | 76 | Path not found |
|
|
|
|
|
|
In cases when it is not practical to prompt a user for additional information (such as during initial startup of the program), it is usually best to report the error in a message box. Then give the user some ideas about how to fix the problem before you exit the program safely. |
|
|
|
|
|